Skip to content

[rpc] Bound length-delimited field length against readable bytes - #3756

Merged
wuchong merged 1 commit into
apache:mainfrom
fresh-borzoni:rpc-field-length-bound
Jul 30, 2026
Merged

[rpc] Bound length-delimited field length against readable bytes#3756
wuchong merged 1 commit into
apache:mainfrom
fresh-borzoni:rpc-field-length-bound

Conversation

@fresh-borzoni

@fresh-borzoni fresh-borzoni commented Jul 23, 2026

Copy link
Copy Markdown
Member

closes #3757
Generated Protobuf decoders allocate new byte[len] for a length-delimited field before checking the declared length fits the bytes present, so a bogus length prefix results in a large allocation.

Added ProtoCodecUtils.readBytesLen, which rejects a length that is negative or larger than the buffer's readable bytes, and route the bytes, string, repeated-bytes and repeated-string decoders through it.

@wuchong wuchong left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fresh-borzoni , LGMT.

@wuchong
wuchong merged commit 917c3f3 into apache:main Jul 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[rpc] RPC decoder allocates before validating field length

2 participants